package com.chis.jxc.service;


import org.springframework.context.support.ClassPathXmlApplicationContext;

import java.util.List;

/**
 * @author wlj
 * @version 2019年05月21日
 * @Description
 * @Company zwx
 */
public class TestMysql extends Thread{

    private static MysqlService mysqlService;
    private String tablename;

    public TestMysql(String tablename) {
        this.tablename = tablename;
    }

    static {
        ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(new String[] {"spring-jdbc.xml"});
        context.start();
        mysqlService = (MysqlService) context.getBean("mysqlService");
    }

    @Override
    public void run() {

        Long l1 = System.currentTimeMillis();
        System.out.println(tablename+" start...");
        try {
            mysqlService.test1(tablename);
        } catch (Exception e) {
            e.printStackTrace();
        }
        System.out.println(tablename + "end , 耗时："+(System.currentTimeMillis()-l1));
    }

    public static void main(String[] args) {



        try {
            for(int i = 7 ; i <= 9 ; i++){
                String tbname = null;
                if(i < 10){
                    tbname="td_jxc_stmtzx_20200"+i;
                }else{
                    tbname="td_jxc_stmtzx_2020"+i;
                }
                TestMysql threadRuning = new TestMysql(tbname);
                threadRuning.start();
            }

        } catch (Exception e){
            e.printStackTrace();
        }

        while (true){
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }


    }
}
